﻿/*
 * Created by SharpDevelop.
 * User: Admin15
 * Date: 15/08/2014
 * Time: 2:44 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;

namespace YoutubeInformationGUI
{
	/// <summary>
	/// Description of Configuration.
	/// </summary>
	public class Configuration
	{
		static Configuration instance;
		public string DbPath { get; set; }
		public string SaveFolder { get; set; }
		public int SleepTime { get; set; }
		public static int CHANNEL_MODE_VIDEO_ONLY=1;
		public static int CHANNEL_MODE_AUDIO_ONLY=2;
		public static int CHANNEL_MODE_BOTH=3;
		public static int CHANNEL_MODE_CUSTOM=4;
		private string iniFileName = "Config.ini";
		private string section = "Config";
		public static Configuration Instance {
			get {
				if(instance == null){
					instance = new Configuration();
					instance.Init();
				}
				return instance; 
			}
		}
		
		public void Init()
		{
			string iniPath = Path.Combine(Environment.CurrentDirectory,iniFileName);
			if(!File.Exists(iniPath)){
				throw new Exception("File not found : " + iniPath);
			}
			IniFile ini = new IniFile(iniPath);
			DbPath = ini.IniReadValue(section,"DbPath");
			SaveFolder = ini.IniReadValue(section,"SaveFolder");
			SleepTime = int.Parse(ini.IniReadValue(section,"SleepTime"));
		}
	
	}
}
